import request from '@/utils/request';
import { ProductUnitVo, ProductUnitQuery, ProductUnitForm } from './types';

// 查询商品单位列表
export const getProductUnitList = (params: ProductUnitQuery) => {
    return request({
        url: '/product/unit/list',
        method: 'get',
        params
    });
};

// 获取商品单位详细信息
export const getProductUnit = (id: number) => {
    return request({
        url: `/product/unit/${id}`,
        method: 'get'
    });
};

// 新增商品单位
export const addProductUnit = (data: ProductUnitForm) => {
    return request({
        url: '/product/unit',
        method: 'post',
        data
    });
};

// 修改商品单位
export const updateProductUnit = (data: ProductUnitForm) => {
    return request({
        url: '/product/unit',
        method: 'put',
        data
    });
};

// 删除商品单位
export const deleteProductUnit = (id: number) => {
    return request({
        url: `/product/unit/${id}`,
        method: 'delete'
    });
};

// 批量删除商品单位
export const deleteProductUnitBatch = (ids: number[]) => {
    return request({
        url: `/product/unit/batch/${ids.join(',')}`,
        method: 'delete'
    });
}; 